Skip to content

fix(deps): restore node-addon-api and node-gyp for sharp's native build fallback - #4673

Merged
JSONbored merged 1 commit into
mainfrom
fix/restore-sharp-native-build-deps
Jul 10, 2026
Merged

fix(deps): restore node-addon-api and node-gyp for sharp's native build fallback#4673
JSONbored merged 1 commit into
mainfrom
fix/restore-sharp-native-build-deps

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

What broke

PR #4660 (#4621) removed node-addon-api/node-gyp based on a source-grep finding zero import
statements — correct about application code, but it missed that sharp's own install script needs
node-addon-api as a build-from-source fallback when no matching prebuilt native binary is available for
the current platform/arch/Node combination. node-gyp performs that build. Neither is ever imported by
source — npm's own postinstall/build machinery pulls them in.

Verified regression

Reproduced on a completely clean, unmodified checkout of current main: npm ci fails outright with
sharp: Please add node-addon-api to your dependencies on macOS arm64 / Node 26. CI didn't catch it
because its runner apparently has a matching prebuilt sharp binary cached, so the source-build fallback
never triggers there — but any local dev setup or self-hoster on a platform without one hits this
immediately.

Fix

Restore both dependencies, regenerate the lockfile. Confirmed rm -rf node_modules && npm ci now
succeeds cleanly, and npm run typecheck passes. @hookform/resolvers's removal (also from #4660) is
unrelated and stays removed.

Fixes #4672

…ld fallback

PR #4660 (#4621) removed these as "unused" based on a source-grep that found
zero import statements -- but sharp's own install script falls back to
building its native binding from source via node-gyp when no matching
prebuilt binary is available for the current platform/arch/Node version,
and that build-from-source path explicitly requires node-addon-api. A
source grep can't see this: npm's own postinstall/build machinery pulls
these in, not application code.

Confirmed as a live, reproducible regression: `npm ci` on a clean checkout
of current main fails outright with "sharp: Please add node-addon-api to
your dependencies" on this platform (macOS arm64, Node 26). CI apparently
didn't catch it because its runner has a matching prebuilt sharp binary
available, so the source-build fallback never triggers there -- but any
local dev setup (or self-hoster) on a platform without one does hit it.

@hookform/resolvers's removal (also part of #4660/#4621) is unaffected and
stays removed -- unrelated to this failure mode.

Fixes #4672
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jul 10, 2026
@JSONbored
JSONbored merged commit dd3560a into main Jul 10, 2026
7 checks passed
@JSONbored
JSONbored deleted the fix/restore-sharp-native-build-deps branch July 10, 2026 11:19
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.13%. Comparing base (7e76b2e) to head (a7b7af5).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4673   +/-   ##
=======================================
  Coverage   94.13%   94.13%           
=======================================
  Files         434      434           
  Lines       38542    38542           
  Branches    14056    14056           
=======================================
  Hits        36282    36282           
  Misses       1601     1601           
  Partials      659      659           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npm ci regression: sharp's native-build fallback needs node-addon-api (removed by #4660)

1 participant